<%@page import="org.springframework.security.core.context.SecurityContextHolder"%>
<%@page import="org.apache.commons.lang.StringUtils"%>
<%@page import="org.apache.commons.lang.time.DateFormatUtils"%>
<%@page import="org.springframework.util.CollectionUtils"%>
<%@page import="java.util.Collection"%>
<%@ include file="../common/common_include.jsp"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>


<%
	SoftForm form = (SoftForm)request.getAttribute("command");
	String isCenter = (String)request.getAttribute("isCenter");
	List<TblOaSoftType> fileTypeList =(List<TblOaSoftType>)request.getAttribute("fileTypeList");
	UserInfo user = (UserInfo)SecurityContextHolder.getContext().getAuthentication().getPrincipal();
	String userName = user.getName();
	String nowDate = DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss");
%>
			<div >
				<form id="noticeFORM" name="form" target="coreIframe"
					action="<%=request.getContextPath()%>/soft/doAdd" method="post" enctype="multipart/form-data">
					<div class="breadcrumb">
						<div class="bcIcon"></div>
						<ul class="bcNav">

							<li>上传软件</li>
						</ul>
					</div>

					<table class="formTable">
						<tr>
							<td class="tdTitle">文件类型:</td>
							<td>
								<select name="typeId" id="softType">
									<%
										if(!CollectionUtils.isEmpty(fileTypeList)){
											for(TblOaSoftType coreFileType: fileTypeList){
												String type = coreFileType.getTypeId()+"";
												String typeName = coreFileType.getFileType();
												%>
										    	<option value="<%=type%>"><%=typeName%></option>
												<%
											}
										}
									%>
								</select>
							</td>
						</tr>
						
						<tr>
							<td class="tdTitle">发布时间:</td>
							<td><input class="inputText xs" type="text"
								name="publicDate" checkNull="true" value="<%=nowDate %>"
								onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" /></td>
						</tr>
						<tr>
							<td class="tdTitle">发布人:</td>
							<td><input class="inputText xs" type="text" name="publicMan" checkNull="true" value="<%=userName%>" /></td>
						</tr>
						<tr>
							<td class="tdTitle">软件名称:</td>
							<td><input class="inputText xs" type="text" name="name" checkNull="true" placeholder="请输入软件名称" />
							<span class="errorTipWrap" id="errorTip_name">
							</td>
						</tr>
						<tr>
							<td class="tdTitle">文件:</td>
							<td>
								<!-- <input class="inputText xs" type="text" name="publicMan" checkNull="true"/> -->
								<sec:authorize ifAllGranted="ADD_SOFT">
									<input type="file" id="multipartFile">
									<span class="uploadResultLabel" id="uploadResultLabel" style="display: inline-block;"></span>
									<div>
										<span class="uploadTip">只能上传doc,docx,xls,xlsx,ppt,pptx,txt,pdf,zip,rar,jpg格式的文件</span>
									</div>
									<input type="hidden" name="tempFileId" value="">
								</sec:authorize>
							</td>
						</tr>
						<tr>
							<td class="tdTitle">软件描述：</td>
							<td class="" colspan="2">
								<div style="padding-top:10px;padding-bottom:10px;">
								<textarea id="content" name="desc" 
								style="width: 700px; height: 200px; visibility: hidden;"></textarea>
								</div>
								<span class="errorTipWrap" id="errorTip_desc">
							</td>
						</tr>
						
						<%if("1".equals(isCenter)){ %>
						<tr id="recRegion">
							<td class="tdTitle">可见区域：</td>
							<td class="" colspan="2">
							<div class="checkbox-wrap">
									<label>
										<input type="checkbox" value="1" name="toZB" id="toZB" class="checkbox" checked="checked">
										<span>广东区</span><span>&nbsp;&nbsp;&nbsp;&nbsp;</span>							
									</label>
									<label>
										<input type="checkbox" value="1" name="toZJ" id="toZJ" class="checkbox">
										<span>浙江区</span><span>&nbsp;&nbsp;&nbsp;&nbsp;</span>
									</label>
									<label>
										<input type="checkbox" value="1" name="toFJ" id="toFJ" class="checkbox">
										<span>福建区</span>
									</label>
								</div>
							</td>
						</tr>
						<%} %>
						<tr>
							<td class="tdTitle"></td>
							<td>
								<div>
									<input class="input-btn-microsoft" type="submit" value="提交">
									<a class="a-btn-microsoft" href="javascript:XF.Soft.manageSoft()">取消</a>
								</div>
							</td>
						</tr>
						
					</table>
				</form>
		</div>
	<iframe name="coreIframe" style="display: none"></iframe>
	<div class="popContainer" id="popContainer" style="display: none;"></div>

<script type="text/javascript">
	$(function() {
		XF.createKindEditor("content");
		$("input[name=name]").focus();
		XF.Soft.init();
	});
	
	$(function() {
		XF.uploadFile("multipartFile","<%=request.getSession().getId()%>");
		<%-- $("#multipartFile").uploadify({
	        auto: true,
	        uploader: "<%=request.getContextPath()%>/servlet/upload?jsessionid=<%=request.getSession().getId()%>",
	        swf: '<%=request.getContextPath()%>/js/jplugin/uploadify/uploadify.swf',
	        onUploadComplete:function(file){
	        	alert("1"+file);
	        }
	    }); --%>
	});
	
	$(function() {
		$("#recRegion").hide();
		$("#softType").change(function(){
			if('<%=isCenter%>'=="1"){
				var softType = $("#softType").val();
				if(softType=="18"){
					$("#recRegion").show();
				}else{
					$("#recRegion").hide();
				}
			}else{
				$('#recRegion').attr("disabled","disabled");
			}
		});
	});
	
</script>